bool serialize(std::string & fileName,const std::vector<std::string> & stringsToSerialize)
{
	FILE *fptr = fopen(fileName.c_str(),"w");
	if(!fptr)
		return false;

		vector<string>::const_iterator i = stringsToSerialize.begin(), end = stringsToSerialize.end();
	for(; i<end;i++ )
	{
		::fputs((*i).c_str(),fptr);
		::fputs("\n",fptr);
	}
	fclose(fptr);
	return true;
}
bool deserialize(std::string & fileName, std::vector<std::string> & deseerializedString)
{
	FILE *fptr = fopen(fileName.c_str(),"r");
	if(!fptr)
		return false;
	char arr[1024],*ptr=NULL;
	while(!feof(fptr))
	{	
		ptr = fgets(arr,1024,fptr);
		if(ptr == arr)
			deseerializedString.push_back(string(arr));
	}	
	fclose(fptr);
	return true;
}

int main()
{
	std::vector<std::string> stringsToSerialize,deseerializedString;
	std::string fileName("serializedString.txt");
	std::string word1("Mastering"),word2("Programming"),word3("Interview"),word4("with"),word5("Arif"),word6("and"),word7("Krishna");
	stringsToSerialize.push_back(word1);
	stringsToSerialize.push_back(word2);
	stringsToSerialize.push_back(word3);
	stringsToSerialize.push_back(word4);
	stringsToSerialize.push_back(word5);
	stringsToSerialize.push_back(word6);
	stringsToSerialize.push_back(word7);
	serialize(fileName,stringsToSerialize);
	deserialize(fileName,deseerializedString);
	vector<string>::iterator i = deseerializedString.begin(), end = deseerializedString.end();
	for(; i<end;i++ )
		cout<<*i;
	getchar();
	return 0;
}